package com.ss.android.article.lite.activity;

import android.app.Activity;
import android.os.Bundle;

import com.ss.android.article.browser.main.ArticleMainActivity;
import com.ss.android.l.c;

import java.lang.ref.WeakReference;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class MainActivity extends ArticleMainActivity {
    private static Set<WeakReference<Activity>> refActivitySet = new HashSet();
    private WeakReference<Activity> mSelfRef = new WeakReference(this);

    public void onCreate(Bundle savedInstanceState) {
        com.bytedance.ttstat.a.beforeOnCreate(this);
        try {
            Iterator<WeakReference<Activity>> iterator = MainActivity.refActivitySet.iterator();
            while (iterator.hasNext()) {
                WeakReference<Activity> refActivity = iterator.next();
                if (refActivity == null) {
                    continue;
                }

                Activity activity = refActivity.get();
                if (activity == null) {
                    continue;
                }
                if (activity == this) {
                    continue;
                }
                activity.finish();
            }

            MainActivity.refActivitySet.clear();
            MainActivity.refActivitySet.add(this.mSelfRef);
        } catch (Throwable throwable) {
        }
        super.onCreate(savedInstanceState);
        com.bytedance.ttstat.a.afterSuperOnCreate(this);
    }

    public void onDestroy() {
        super.onDestroy();
        try {
            MainActivity.refActivitySet.remove(this.mSelfRef);
        } catch (Throwable throwable) {
        }
    }

    public void onResume() {
        com.bytedance.ttstat.a.beforeSuperOnResume(this);
        super.onResume();
        com.bytedance.ttstat.a.afterSuperOnResume(this);
    }

    public void showSettingDialog() {
        super.showSettingDialog();
    }
}

